﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;

namespace BISPOS
{
    public partial class CustomerInvoiceDetailsUserControl : DevExpress.XtraEditors.XtraUserControl
    {
        Invoice Invoice;
        BISPOS.Repository.InvoiceRepository invoiceRepository = new Repository.InvoiceRepository();
        Customer Customer;
        public CustomerInvoiceDetailsUserControl(List<Invoice> Invoices)
        {
            InitializeComponent();
            Customer = Invoices.Select(x => x.Customer).Distinct().FirstOrDefault();
        }
        public void ChangeInvoice(Invoice invoice)
        {
            Invoice = invoice;
            dateTextEdit.Text = invoice.Date.ToShortTimeString() + " - " + invoice.Date.ToShortDateString();
            paymentTypeTextEdit.Text = invoice.PaymentType.FullText;
            employeeTextEdit.Text = invoice.Employee.Name;

            invoiceItemslinqServerModeSource.QueryableSource = invoice.InvoiceItems.AsQueryable();
            

            totalPriceTextEdit.Text = Invoice.TotalPrice.ToString("n2");
            invoiceItemsgridView.SelectRow(-1);

        }




    }
}
